package com.bestv.search.management.datasyn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcTest {

    public static void main(String[] args) throws Exception {
        String sDBDriver = "oracle.jdbc.driver.OracleDriver";
        String sConnStr = "jdbc:oracle:thin:@61.8.162.83:1521:orcl";

        Connection conn = null;
        ResultSet rs = null;
        Statement stmt = null;
        try {
            Class.forName(sDBDriver);
            conn = DriverManager.getConnection(sConnStr, "staimsp", "staimsp");
            stmt = conn.createStatement();

            rs = stmt
                    .executeQuery("select * from imsp_program_view where update_time >= to_date('2010-03-11 16:50:00','YYYY-MM-DD HH24:MI:SS')");
            int i = 0;
            while (rs.next() && i < 5) {
                System.out.println(i + "---" + rs.getString(1));
                i++;
            }
            rs.close();

        } catch (Exception e) {
            System.out.println(e);
        } finally {
            if (conn != null)
                conn.close();
            if (stmt != null)
                stmt.close();
            if (rs != null)
                rs.close();
        }

    }

}
